﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>驰骋工作流</title>
    <script language="JavaScript" src="../../../Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <!-- 自己的系统风格统一. -->
    <link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="../Admin.js"></script>
    <style>
        #Btn_Save {
            background-image: url(../../../Img/Btn/Save.png) !important;
            background-repeat: no-repeat;
            background-size: 15px;
            background-position-y: 5px;
        }
    </style>
    <script type="text/javascript" language="javascript">
        var fk_node = GetQueryString("FK_Node");
        var type = GetQueryString("Type") || "Add";
        var node = new Entity("BP.WF.Node", fk_node);

        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });
        //初始化数据.
        function InitPage() {


            //调用公共类库的方法:执行批量主表赋值.
            // GenerBindEnumKey("DDL_BRole", "BatchRole", node.BatchRole);

            //获得属性集合.
            var attrs = new Entities("BP.Sys.MapAttrs");
            attrs.Retrieve("FK_MapData", "ND" + fk_node, "GroupID,Idx");

            var groups = new Entities("BP.Sys.GroupFields");
            groups.Retrieve("FrmID", "ND" + fk_node, "Idx");

            //增加处理.
            var BatchFields = node.GetPara("BatchFields") || "";
            if (type == "Edit")
                BatchFields = node.GetPara("EditFields") || "";

            //分组.
            for (var idx = 0; idx < groups.length; idx++) {
                var gf = groups[idx];
               // if (gf.CtrlType != '')
                 //   continue;

                var newRow = "";
                newRow += "<tr>";
                newRow += "<td colspan=4><b>" + gf.Lab + "</b></td>";
                newRow += "</tr>";
                $("#table1 tr:last").after(newRow);

                var num = 0;
                for (var i = 0; i < attrs.length; i++) {

                    var item = attrs[i];
                    if (item.UIVisible == false)
                        continue;

                    if (gf.OID != item.GroupID)
                        continue;

                    num++;
                    var newRow = "";
                    newRow = "<tr ><td class=Idx>" + num + "</td>";
                    if (BatchFields == "" || BatchFields.indexOf(item.KeyOfEn) == -1) {
                        newRow += "<td><label><input name='CB_Node' type='checkbox' value='" + item.KeyOfEn + "' />" + item.KeyOfEn + "</label></td>";

                    } else {
                        newRow += "<td><label><input name='CB_Node' type='checkbox' value='" + item.KeyOfEn + "' checked='checked' />" + item.KeyOfEn + "</label></td>";
                    }
                    newRow += "<td>" + item.Name + "</td>";
                    newRow += "<td>" + item.LGTypeText + "</td>";
                    newRow += "</tr>";
                    $("#table1 tr:last").after(newRow);
                }
            }
            //$("#DDL_BRole").val(node.BatchRole);

            return;
        }



        function Btn_Save_Click() {

            $("#Btn_Save").html('正在保存请稍候...');

            var checkBoxIDs = "";
            var cb = $("input[name='CB_Node']:checked").each(function (j) {
                checkBoxIDs += $(this).val() + ","; //获得所有的 checkBox ID传入到后台去,用于解决checkbox控件，在没有被选择的时候，没有值的问题。
            });
            if (type == "Add")
                node.SetPara("BatchFields", checkBoxIDs)
            if (type == "Edit")
                node.SetPara("EditFields", checkBoxIDs);
            node.Update();
            //alert(checkBoxIDs)
            //var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_AttrNode");
            //handler.AddPara("FK_Node", GetQueryString("FK_Node"));
            //handler.AddPara("CheckBoxIDs", checkBoxIDs);
            //handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
            //handler.AddFormData();
            //var data = handler.DoMethodReturnString("BatchStartFields_Save");

            //if (data.indexOf('err@') >= 0) {
            //    alert(data);
            //    return;
            //}
            Reload();
            return;

        }
    </script>
</head>
<body>

    <form id="cc">
        <div style="right:30px; position:absolute; z-index:100; top:-4px">
            <input type="button" ID="Btn_Save" runat="server" value="保存" onclick="Btn_Save_Click()" />
        </div>
        <div style="position:relative;">
            <table style="width: 100%;">
                <!--<caption><img style="margin-bottom:8px;" align="middle" src='../../../Img/Event.png' />批处理规则设置</caption>
                <tr>
                    <td colspan="1">规则设置：</td>
                    <td colspan="2">
                        <select ID="DDL_BRole" name="DDL_BRole" style="width:130px">
                            <option value="0"> 不可以 </option>
                            <option value="1"> 批量审批 </option>
                            <option value="2"> 分组批量审核 </option>

                        </select>
                    </td>
                    <td><a href="http://doc.ccbpm.cn/?v=5404&t=17920" target="_blank">帮助</a> </td>
                </tr>
                <tr>
                    <td colspan="1">显示的行数：</td>

                    <td colspan="2">
                        <input type="text" value="12" ID="TB_BatchListCount" name="TB_BatchListCount" runat="server" style="width:56px" />
                    </td>

                    <td> 0表示显示所有</td>
                </tr>-->
                <tr>
                    <td class="Sum" colspan="4">
                        批量发起字段(需要显示的字段.)
                    </td>
                </tr>


                <tr>
                    <td colspan="4">

                        <table style=" width:100%;" id="table1">
                            <tr>
                                <th>序</th>
                                <th>字段</th>
                                <th>名称 </th>
                                <th>类型</th>
                            </tr>


                        </table>

                    </td>
                </tr>
            </table>
        </div>
    </form>

</body>
</html>
